<!-- /* Description for file.
 * 面试题目-查看试卷和操作其下题目页面
 *
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/interviewquestions
 * @since         ues
 * @version       V0.0.1
 * @modifiedby    张海杰2011年0706
 * @lastmodified  张海杰2011年0706
 */-->
<?php
echo $html->css ( 'tab' );
echo $html->css ( 'interviewquestions_screen' );
echo $html->css ( 'jquery.treeview' );
echo $javascript->link ( 'jquery-treeview/jquery.treeview' );
echo $javascript->link ( 'jquery-treeview/jquery.cookie' );
?>
<script type="text/javascript">
	$(document).ready(function(){
		$("#black").treeview();
		self.parent.frames["Interview_tree"].location.href=self.parent.frames["Interview_tree"].location.href;//到父窗口找到tree的iframe刷新数据
	});
</script>
<script type="text/javascript">
function getDelStr() {
	var delArr = $("#InterviewquestionDeleteSomeForm :checkbox:checked");
	if(delArr.length==0)
	{
		alert("请选择你要删除的项!");
		return;
	}
	var str = "";
	for(var i=0;i<delArr.length;i++) {
		var del = delArr[i].value;
		str += del;
		str += "/";
	}
	//window.alert(str);
	$("#delStr").val(str);
	//window.alert($("#delStr").val());
	var fatherid = "";
	fatherid = $("#InterviewquestionId").val();
	//alert(fatherid);
	$("#InterviewquestionDeleteSomeForm").submit();
	//window.location.open('<?php echo ROOT_WEB_PATH; ?>/interviewquestions/view/'+ fatherid );	
	//window.location.reload();
}

function getfatherid(){
	var fatherid = "";
	var addStr=$("#InterviewquestionDeleteSomeForm :checkbox:checked");
	if(addStr.length==0){
		fatherid = $("#InterviewquestionId").val(); //没选checkbox传本试卷的id
	}
	else if(addStr.length==1){
		fatherid = $("#InterviewquestionDeleteSomeForm :checkbox:checked").val();//选中checkbox传此题目的id
	}
	else{
		alert("请只选择一个技能测试项目添加面试题目！");
		return;
	}
	//alert(fatherid);
	//	window.location='<?php echo ROOT_WEB_PATH; ?>/interviewquestions/add/'+ fatherid;
	window.open('<?php echo ROOT_WEB_PATH; ?>/interviewquestions/add/'+ fatherid );	
}
function getfatheridtoedit(){
	var fatherid = "";
	var addStr=$("#InterviewquestionDeleteSomeForm :checkbox:checked");
	if(addStr.length==0){
		fatherid = $("#InterviewquestionId").val(); //没选checkbox传本试卷的id
	}
	else if(addStr.length==1){
		fatherid = $("#InterviewquestionDeleteSomeForm :checkbox:checked").val();//选中checkbox传此题目的id
	}
	else{
		alert("请只选择一个技能测试项目修改面试题目！");
		return;
	}
	//alert(fatherid);
	//	window.location='<?php echo ROOT_WEB_PATH; ?>/interviewquestions/add/'+ fatherid;
	window.open('<?php echo ROOT_WEB_PATH; ?>/interviewquestions/edit/'+ fatherid );	
}
//点击题目添加
$(document).ready(function(){		
	$(".newitems").click(function(){
		getfatherid();
	});
	$(".edititems").click(function(){
		getfatheridtoedit();
	});
//	var paperid = $("#InterviewquestionId").val();
//	var k = 0;
//	var i = 1;
//	var j = 1;		
//	var bigitem;
//	var bigitemid;
//	$(":checkbox").each(function(){ 
//		k++;
//		}); 
//	var tablelength = (k + 1 )/2;
//	//alert(tablelength);   //表格高度
//	$("td[class^='itemtd_']").each(function(){
//		if($(this).find("h2").text()== paperid){
//			$(this).prepend("<span>"+i+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>");
//			bigitem = $(this).find("h1").text();
//			bigitemid = i;
//			//alert(bigitem);
//			i++;
//		}
//		else {
//				if($(this).find("h2").text()== bigitem){
//					$(this).prepend("<span>"+bigitemid+"."+j+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>");
//					j++;
//					//alert(j);
//					
//				}
//				else
//				{
//					$(this).prepend('<div style="float:left;padding-left:'+tablelength+'0px'+ '">&nbsp;</div>');
//					//tablelength = tablelength +3;
//					j = 1;
//				}
//		}
//	});
	
});
</script>

 <div class="tabflex">
 <?php echo $form->create('Interviewquestion',array('action'=>'view','type'=> 'post'));?>
 	<fieldset><legend><?php __('Interviewquestion Management');?></legend>
		<table width="100%" cellspacing="0" cellpadding="0" border="0" class="viewtable" >
			<tr>
			<td>
			<?php
				echo $form->input('id',array('default'=>$interviewquestion['Interviewquestion']['id']));
				echo $form->hidden('creater');
				echo $form->hidden('updater');
				echo $form->hidden('fatherId',array('value'=>$interviewquestion['Interviewquestion']['fatherId']));?> </td>
			</tr>
			<tr>
				<td width="50"></td>
				<td width="100"><?php __('InterviewquestionName');//名称?>:</td>
				<td>
				<?php echo $interviewquestion['Interviewquestion']['name']; ?>
				</td>
				<td width="50"></td>
				<td width="100"><?php __('InterviewquestionScore');//分数?>:</td>
				<td >
				<?php echo $interviewquestion['Interviewquestion']['score']; ?>
				</td>
			</tr>
			<tr>
				<td width="50"></td>
				<td width="100"><?php __('InterviewquestionMemo');//备注?>:</td>
				<td colspan="4">
				<?php echo $interviewquestion['Interviewquestion']['memo']; ?>
				</td>
			</tr>
		</table>
	</fieldset>	
<?php echo $form->end();?>
<table width="50%" cellspacing="0" cellpadding="0" border="0">
	<tr><!--
		<td width="100px">
			<a href="<?php echo ROOT_WEB_PATH; ?>/interviewquestions/edit/<?php //echo $interviewquestion['Interviewquestion']['id']?>"><?php //echo $html->image('edit.gif', 
		 							//array('alt' =>  __('Edit', true),'title'=> '修改试卷','border'=>'0')); ?>&nbsp;修改试卷</a>
		</td>
			--><!-- 修改试卷 -->	
		<td width="100px">
			<a class="edititems" ><?php echo $html->image('edit.gif', 
		 							array('alt' =>  __('Edit', true),'title'=> '修改','border'=>'0')); ?>&nbsp;修改</a>
		</td>
		<td width="100px">
			<a href="<?php echo ROOT_WEB_PATH; ?>/interviewquestions/delete/<?php echo $interviewquestion['Interviewquestion']['id']?>"><?php echo $html->image('delete.gif', 
		 							array('alt' =>  __('Delete', true),'title'=> '删除试卷','border'=>'0')); ?>&nbsp;试卷删除</a>
		</td>
		<td width="100px"><a class="newitems" ><?php echo $html->image('add.gif', 
		 							array('title'=>'新增题目','border'=>'0','class'=>'newitems')); ?>&nbsp;新增题目</a>
		 							
		 </td>
			<!-- 新增题目 -->	
		
		<td width="100px"><a onclick="getDelStr()" ><?php echo $html->image('delete.gif', 
		 							array('title'=>'删除题目','border'=>'0','onclick'=>'getDelStr()')); ?>&nbsp;<?php echo __('Delete Interviewquestion', true);?></a>
		</td>
	</tr>
	</table>
</div>
<div id="maintree-onepaper">
<?php echo $form->create('Interviewquestion',array('action'=>'deleteSome','type'=> 'post'));?>
<?php echo $form->hidden('delStr',array('name'=>'interviewquestionsid','id'=>'delStr'));?>

<?php $first='';
	if (count($interviewquestions)>0){
		echo "<ul id='black' style='border-top:0px solid #abcfe0;'>";
			for ($i=0;$i<count($interviewquestions);$i++){
				if($interviewquestions[$i]['Interviewquestion']['fatherId']==0){
					echo "<li style='padding-left:0px;padding-top:0px;'>";
					echo "<span class='folder'>";
?>
	<table width="100%" cellpadding="0" cellspacing="0" class="tab1" id="sortable" >
	<tr>
			<th><?php echo __('skillName');?></th>
			<th width="70px"><?php echo __('skillScore');?></th>
	</tr>
	</table>
<?php
					echo "</span>";//试卷
					for($j=0;$j<count($datas);$j++){
						if($datas[$j]['Interviewquestion']['fatherId']==$interviewquestions[$i]['Interviewquestion']['id']){
							echo "<ul>";
							echo "<li>";
							echo "<a>";		
							echo $form->checkbox($datas[$j]['Interviewquestion']['id'], array('value' => $datas[$j]['Interviewquestion']['id']));
							$first++;
							echo "<font class='highlight'>".$first."</font>";
							echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
							echo $datas[$j]['Interviewquestion']['name'];//试卷的第一层题目
							echo "</a>";
							echo "<div style='float:right;margin-top:-22px;margin-right:48px;'>".$datas[$j]['Interviewquestion']['score']."</div>";	
							echo getTree($datas,$datas[$j]['Interviewquestion']['id'],$first,48);
							echo  "</li>";
							echo  "</ul>";
						}
					}
					
					echo  "</li>";
				}
			}
		echo "</ul>";
		
//		for($k=0;$k<count($datass);$k++){
//		echo $datass[$k]['Interviewquestion']['name'];
//		echo "=======";
//		}
	}
	function getTree($datas, $pId , $f = null,$ff=null)
	{
		$html = '';
		$second =0;
		$ii='';
			foreach($datas as $k => $v)
			{
			   if($v['Interviewquestion']['fatherId'] == $pId)
			   {         //父亲找到儿子
			   	$second++;
			    $html .= "<li><a>";
			    $html .= "<input type='checkbox' value=".$v['Interviewquestion']['id']." id=".$v['Interviewquestion']['id']." /></inpu>";
			    $html .= "<font class='highlight'>".$f.".".$second."</font>";
			    $ii= $ff + $second*16;
			    $html .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			    $html .= $v['Interviewquestion']['name'];
			    $html .= "</a>";
			    $html .= "<div style='float:right;margin-top:-22px;padding-right:".$ii."px'>".$v['Interviewquestion']['score']."</div>";
			    $html .= getTree($datas, $v['Interviewquestion']['id'],$f.".".$second,$ii);
			    $html = $html."</li>";
			   }
			   else{
			   	$ii= $ff - $second*16;
			   }
			}
			return $html ? '<ul>'.$html.'</ul>' : $html ;
	}
?>

<?php echo $form->end();?>
</div>

